package com.wuhuiyue.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuhuiyue.entity.Channelvo;
import com.wuhuiyue.entity.Result;
import com.wuhuiyue.entity.Search;
import com.wuhuiyue.service.IChannelvoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author hy-woo
 * @since 2022-06-14
 */
@RestController
@RequestMapping("/channelvo")
public class ChannelvoController {

    @Autowired
    IChannelvoService channelvoService;

    @RequestMapping("/page")
    public Result page(@RequestBody Search search){
        Page<Channelvo> channelvoPage = new Page<>(search.getPage(), search.getPageSize());
        QueryWrapper<Channelvo> wrapper = new QueryWrapper<>();
        if (StringUtils.hasText(search.getKey())){
            wrapper.like("fname",search.getKey());
        }
        if (search.getAppid()!=null){
            wrapper.eq("appid",search.getAppid());
        }
        if (search.getVersionsId()!=null){
            wrapper.eq("versions_id",search.getVersionsId());
        }
        if (search.getTypeId()!=null){
            wrapper.eq("type_id",search.getTypeId());
        }
        if (search.getDatea()!=null){
            wrapper.gt("created",search.getDatea());
        }
        if (search.getDateb()!=null){
            wrapper.lt("created",search.getDateb());
        }
        Page<Channelvo> page = channelvoService.page(channelvoPage, wrapper);
        return Result.OK(page);
    }
}
